import { createRouter, createWebHistory } from 'vue-router'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import type { RouteRecordRaw } from 'vue-router'
import Layout from '@/layout/index.vue'

// declare module 'vue-router' {
//   interface _RouteRecordBase {
//     hidden?: boolean | string | number
//   }
// }

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    redirect: 'home'
  },
  /* 登陆页面 */
  // {
  //   path: '/login',
  //   name: 'login',
  //   meta: {
  //     hidden: true
  //   },
  //   component: () => import('@/views/login/index.vue')
  // },
  // {
  //   path: '/register',
  //   name: 'register',
  //   meta: {
  //     hidden: true
  //   },
  //   component: () => import('@/views/login/register.vue')
  // },
  // {
  //   path: '/password',
  //   name: 'resetpassword',
  //   meta: {
  //     hidden: true
  //   },
  //   component: () => import('@/views/login/resetPassword.vue')
  // },
  /* layout 页面 */
  {
    path: '/home',
    name: 'Home',
    component: Layout,
    redirect: '/home/index',
    children: [
      {
        path: 'index',
        name: 'Home',
        component: () => import('@/views/home/index.vue'),
        meta: {
          title: '首页',
          icon: 'House'
        }
      }
    ]
  },
  // 产品详情页面
  {
    path: '/productDetail',
    name: 'ProductDetail',
    component: Layout,
    redirect: '/productdetail/index',
    children: [
      {
        path: 'index',
        name: 'ProductDetail',
        component: () => import('@/views/productDetail/index.vue'),
        meta: {
          title: '产品详情页',
          icon: 'House'
        }
      }
    ]
  },
  // 搜索详情页面
  {
    path: '/searchDetail',
    name: 'SearchDetail',
    component: Layout,
    redirect: '/searchDetail/index',
    children: [
      {
        path: 'index',
        name: 'SearchDetail',
        component: () => import('@/views/searchDetail/index.vue'),
        meta: {
          title: '搜索详情页',
          icon: 'House'
        }
      }
    ]
  },
  /* 404页面 */
  {
    path: '/:pathMatch(.*)*',
    meta: {
      hidden: true
    },
    name: 'not-found',
    component: () => import('@/views/error/404.vue')
  }
]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
})

export default router
